package org.stayfool.mqtt.test;

import org.junit.Test;
import org.stayfool.client.MqttClient;
import org.stayfool.client.MqttOption;
import org.stayfool.client.util.message.IDUtil;

import java.util.concurrent.CountDownLatch;

/**
 * Created on 2016/12/28.
 *
 * @author stayfool
 */
public class MultiClient {

    @Test
    public void multiClient() {

        int num = 100000;

        MqttOption option = MqttOption.instance()
                .host("localhost")
                .port(1883)
                .loglevel("error");
        for (int i = 0; i < num; ) {
            String id = IDUtil.uuid();
            MqttClient client = new MqttClient(option.clientId("d:1:1:wifi:" + id + ":" + id));
            client.connect();
            System.out.println(i++);
        }

        CountDownLatch latch = new CountDownLatch(1);
        latch.countDown();
    }

}
